package com.example.day3mvp.mvp.view.activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.day3mvp.R;
import com.example.day3mvp.RenManager;
import com.example.day3mvp.di.component.DaggerLoginComponent;
import com.example.day3mvp.di.module.LoginModule;
import com.example.day3mvp.mvp.contrat.LoginContrat;
import com.example.day3mvp.mvp.model.LoginModel;
import com.example.day3mvp.mvp.presenter.LoginPresenter;
import com.example.mylibrary.mvp.view.BaseActivity;

import javax.inject.Inject;

public class LoginActivity extends BaseActivity<LoginPresenter>implements LoginContrat.LoginView, View.OnClickListener {
    private EditText et1;   //控件
    private EditText et2;
    private Button bt;

    @Inject
    RenManager renManager;

    //提供布局
    @Override
    public int bandLayout() {
        return R.layout.activity_login;
    }

    //注入
    @Override
    public void inject() {
        DaggerLoginComponent.builder().loginModule(new LoginModule(this)).build().inject(this);
    }

    //点击事件
    @Override
    public void onClick(View v) {
        mPresenter.login();
        Log.i("TAG", "onClick: ----->"+v);
        renManager.show();

    }

    @Override
    public String getUserName() {
        return et1.getText().toString().trim();
    }

    @Override
    public String getPwd() {
        return et2.getText().toString().trim();
    }

    @Override
    public void goMain() {
        startActivity(new Intent(this,MainActivity.class));

        finish();
    }


    //初始化
    @Override
    public void initView() {

        et1 = (EditText) findViewById(R.id.et1);
        et2 = (EditText) findViewById(R.id.et2);
        bt = (Button) findViewById(R.id.bt);
        bt.setOnClickListener(this);

    }

    @Override
    public void initData() {

    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}
